<template>
  <DatasetList paginationPosition="left"
               :searchForm="searchForm"
               :permission="permission"
               :collapse.sync="collapse"
               :disabledRowFormat="disabledRowFormat"
               :formatRow="formatResoureList"
               :filterProps="{
      modelNumLabel: $t('statement.lr'),
      sharedAuth: false,
      lastSyncDateAuth: false,
      readNumAuth: false,
      receivedNumAuth: false,
      readyNumAuth: false
    }"
               ref="widget-list"
               model="selection"
               pagination-position="right"
               :formatSelection="formatSelection"
               @event:select="onSelect">

  </DatasetList>
</template>

<script>
import DatasetList from '@/views/modules/dataset/list/index'
import { merge, cloneDeep } from 'lodash'
import { PAGE_SETTING } from '@/components/storybook/settings/page'

export default {
  name: 'MediaDataset',
  components: {
    DatasetList
  },
  props: {

    rootBusinessType: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      collapse: false,
      searchForm: {
        name: '',
        internal: false,
        orderField: '',
        resourceType:5,
        version: 1,
        order: [{ sort: 'DESC', field: 'update_date' }],
        filter: {
          type: ["Custom", "Template"]
        },
        integration: {
          showAllIntegration: false,
          integrationGroup: []
        },
        pagination: merge(cloneDeep(PAGE_SETTING), {
          total: 0,
          pageSize: 20
        })
      },
      permission: {
        sharedAuth: false,
        lastSyncDateAuth: false,
        moreMenuAuth: false,
        collectAuth: false,
        fastAuth: false
      },
    }
  },

  methods: {
    formatSelection (item) {
      return item
    },
    formatResoureList (item) {
      if (item.type === 100101) {
        item.createName = item.companyName
        item.businessTypeName = 'Community'
      } else {
        item.createName = item.creatorName
        item.businessTypeName =
          item.businessType === 'MSPbots Internal'
            ? 'Internal'
            : item.businessType
      }
      return item
    },
    disabledRowFormat (item) {
      return false
    },
    onSelect (rows) {
      this.$emit('event:add',rows)
    }
  }
}
</script>
